//
//  MCFunction.h
//  MClient
//
//  Created by  史正烨 on 09-10-23.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>

#ifndef __IPHONE_3_2	// if iPhoneOS is 3.2 or greater then __IPHONE_3_2 will be defined
typedef enum {
    UIUserInterfaceIdiomPhone,           // iPhone and iPod touch style UI
    UIUserInterfaceIdiomPad,             // iPad style UI
} UIUserInterfaceIdiom;

#define UI_USER_INTERFACE_IDIOM() UIUserInterfaceIdiomPhone
#endif // ifndef __IPHONE_3_2

@interface MCFunction : NSObject {

}
+ (void)labelColor:(UILabel*)label;

+ (void)pushViewByUrl:(NSDictionary *)url 
		   parameters:(NSMutableDictionary *)parameters 
	   confirmMessage:(NSString *)confirmMessage
	   naviController:(UINavigationController*)naviController;

+ (NSInteger) cellHeight:(int)lableStyle 
			   withTitle:(NSString *)aTitle 
			   withValue:(NSString *)aValue
			 withAppItem:(NSMutableDictionary *)aAppItem;

#pragma mark --- 高级样式，一行多列 开始 ---

#pragma mark --- 高级样式，一行多列 编辑表单开始 ---

+ (void)addCellForEditForm:(UITableView *)tableView 
				   appItem:(NSMutableDictionary *)appItem
				 indexPath:(NSIndexPath *)indexPath
					   row:(int)row
				  formView:(UIView *)formView
					  cell:(UITableViewCell *)cell 
						 x:(int)x
						 y:(int)y 
					target:(id)target;

+ (UITableViewCell *)createCellForEditForm:(UITableView *)tableView 
								   appItem:(NSMutableDictionary *)appItem
								 indexPath:(NSIndexPath *)indexPath
									   row:(int)row
								  formView:(UIView *)formView
										 x:(int)x
										 y:(int)y 
									target:(id)target;

+ (void)selectDetailForEditFormByAppItem:(UIViewController *)viewController
								withCell:(UITableViewCell *)aCell 
								 appItem:(NSMutableDictionary *)appItem 
								  record:(NSMutableDictionary *)record 
							 isQueryForm:(bool)isQueryForm
									 tag:(int)tag;

#pragma mark --- 高级样式，一行多列 浏览表单开始 ---

+ (void)addCellForViewForm:(UITableView *)tableView 
				   appItem:(NSMutableDictionary *)appItem
				 indexPath:(NSIndexPath *)indexPath
					   row:(int)row
				  formView:(UIView *)formView
					  cell:(UITableViewCell *)cell 
						 x:(int)x
						 y:(int)y 
					target:(id)target;

+ (UITableViewCell *)createCellForViewForm:(UITableView *)tableView 
								   appItem:(NSMutableDictionary *)appItem
								 indexPath:(NSIndexPath *)indexPath
									   row:(int)row
								  formView:(UIView *)formView
										 x:(int)x
										 y:(int)y 
									target:(id)target;

+ (void)selectDetailForViewForm:(UIViewController*)viewController
					   withCell:(UITableViewCell *)aCell 
						appItem:(NSMutableDictionary *)appItem 
						   data:(NSMutableDictionary *)fieldData
							tag:(int)tag;

#pragma mark --- 高级样式，一行多列 结束 ---


+ (UITableViewCell *)createCellForEditForm:(UITableView *)tableView 
								   appItem:(NSMutableDictionary *)appItem
								 indexPath:(NSIndexPath *)indexPath
								  formView:(UIView *)formView;

+ (void)filePreview:(UIViewController*)viewController
		   dataFrom:(NSString *)dataFrom
		   fileInfo:(NSMutableDictionary *)fileInfo;

+ (void)selectDetailForEditFormByAppItem:(UIViewController *)viewController
								withCell:(UITableViewCell *)aCell 
								 appItem:(NSMutableDictionary *)appItem 
								  record:(NSMutableDictionary *)record
							 isQueryForm:(bool)isQueryForm;

+ (UITableViewCell *)createCellForCustomForm:(UITableView *)tableView 
									 appItem:(NSMutableDictionary *)appItem
								   indexPath:(NSIndexPath *)indexPath
									formView:(UIView *)formView;

+ (UITableViewCell *)createCellForViewForm:(UITableView *)tableView 
								   appItem:(NSMutableDictionary *)appItem
								 indexPath:(NSIndexPath *)indexPath
								  formView:(UIView *)formView;

+ (void)selectDetailForViewForm:(UIViewController*)viewController
					   withCell:(UITableViewCell *)aCell 
				  withIndexPath:(NSIndexPath*)aIndexPath
						appItem:(NSMutableDictionary *)appItem 
						   data:(NSMutableDictionary *)fieldData;

+ (UITableViewCell *) createCellForQueryForm:(UITableView *)tableView 
									 appItem:(NSMutableDictionary *)appItem
								   indexPath:(NSIndexPath *)indexPath
									formView:(UIView *)formView;

+ (void)selectDetailForQueryForm:(UIViewController*)viewController
						withCell:(UITableViewCell *)aCell  
						 appItem:(NSMutableDictionary *)appItem 
						  record:(NSMutableDictionary *)record;

+ (void)replaceAndGo:(NSMutableDictionary *)url 
		  parameters:(NSMutableDictionary *)parameters 
	  confirmMessage:(NSString *)confirmMessage 
	  naviController:(UINavigationController*)naviController;

+ (void)refreshAndGoParentView:(UIViewController*)viewController;

+ (void)refreshCurrentView:(UIViewController*)viewController;

+ (Boolean)isEditForm:(UIViewController*)viewController;

+ (NSString *)StringFromDate:(NSDate *)aDate 
					  format:(NSString *)aFormat;
+(NSDate *)DateFromString:(NSString *)string 
				   format:(NSString *)aFormat;

+ (NSString *)getTempFileName:(NSString *)extName;

+ (NSString *)machine;

+ (UIButton *)buttonWithTitle:(NSString *)title
					   target:(id)target
					 selector:(SEL)selector
						frame:(CGRect)frame
						image:(UIImage *)image
				 imagePressed:(UIImage *)imagePressed
				darkTextColor:(BOOL)darkTextColor;

+ (UIButton *)createHelpButton:(id)target
					  selector:(SEL)selector
						 frame:(CGRect)frame;
+ (void)goUrl:(UIViewController*)viewController withUrl:(NSString *)urlString;

+ (UIImage *) scaleAndRotateImage:(UIImage*)photoimage 
							width:(CGFloat)bounds_width 
						   height:(CGFloat)bounds_height;

+ (NSString *) getQueryName:(NSString *)fieldName 
				  queryMode:(NSString*) queryMode;

// 向navgationcontroller中push controller
//{@第一个函数是传进来对象，第二个是传进来类名
+ (void)pushViewController:(UIViewController *)viewController;
//@}

//将十六进制的颜色值转换为uicolor:rrggbbhh
+ (UIColor*)hexColor:(NSString*)hexColor;
//抓取屏幕图像
+ (void)saveScreen:(UIWindow*)window;

+ (NSString*)documentPath;

+ (void)unzipFile:(NSString*)aZipFile withPath:(NSString*)aPath;

+ (NSString *)getAppName;

#pragma mark --- 多选回填列表，值操作函数 ---
//初始化选中
+ (NSMutableArray *)initSelectedValue:(NSString*)aValue;

//选中和不选中时更新
+ (void)updateSelectedValue:(NSMutableArray *)valueArray
					  value:(NSString*)aValue
				   selected:(bool)isSelect;

//获取选中结果
+ (NSString *)getSelectedValue:(NSMutableArray *)valueArray;
@end
